﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Warehouse.DataAccess
{
    public partial class PaymentDetail : CustomeEntity<PaymentDetail>
    {
        protected override System.Linq.Expressions.Expression<Func<PaymentDetail, bool>> GetPredicate()
        {
            return p => p.ID == this.ID;
        }

        #region Public Static Methods
        public static PaymentDetail GetOne(int Id)
        {
            using (WarehouseClassesDataContext context = new WarehouseClassesDataContext())
            {
                return (from t in context.PaymentDetail where t.ID == Id select t).SingleOrDefault();
            }
        }

        public static PaymentDetail[] GetPaymentDetailsByPruchageBillID(Guid purchaseBillId)
        {
            using (WarehouseClassesDataContext context = new WarehouseClassesDataContext())
            {
                return (from t in context.PaymentDetail where t.BillID == (from p in context.PaymentBill where p.PruchageBillID == purchaseBillId select p.ID).SingleOrDefault() select t).ToArray();
            }
        }
        #endregion
    }
}
